// MFCRichEdit.cpp : implementation file
//

#include "stdafx.h"
#include "MSDNApp.h"
#include "MSDNView.h"
#include "MSDNDoc.h"

// CMSDNView

IMPLEMENT_DYNCREATE(CMSDNView, CView)

CMSDNView::CMSDNView()
{

}

CMSDNView::~CMSDNView()
{
}

BEGIN_MESSAGE_MAP(CMSDNView, CView)
END_MESSAGE_MAP()



void CMSDNView::OnDraw(CDC* /*pDC*/)
{
	CMSDNDoc* pDoc = GetDocument();
	//ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: add draw code for native data here
}

// CMSDNView diagnostics

#ifdef _DEBUG
void CMSDNView::AssertValid() const
{
	CView::AssertValid();
}

#ifndef _WIN32_WCE
void CMSDNView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif
#endif //_DEBUG


CMSDNDoc* CMSDNView::GetDocument() const // non-debug version is inline
{
	//ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMSDNDoc)));
	return (CMSDNDoc*)m_pDocument;
}


BOOL CMSDNView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}


void CMSDNView::OnInitialUpdate()
{
	CView::OnInitialUpdate();
}

// CMSDNView message handlers

HRESULT STDMETHODCALLTYPE CMSDNView::CreateWnd(saf::IGenericPanel *pParent, HWND hWndParent)
{
	CWnd *pWnd = (CWnd*)this;
	CWnd *wndParent = CWnd::FromHandle(hWndParent);
	CRect _Rect(0,0, 100, 100);
	//WS_HSCROLL|WS_VSCROLL|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE|ES_MULTILINE|ES_AUTOHSCROLL|ES_LEFT,
	if (pWnd->Create(NULL, _T(""),
		WS_HSCROLL|WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_LEFT|ES_MULTILINE|ES_WANTRETURN,
		_Rect, wndParent, 0))
	{
		//this->GetEditCtrl().SetLimitText(100);
		::SendMessage(m_hWnd, WM_SETFONT, (WPARAM)::GetStockObject(DEFAULT_GUI_FONT), 0);
		return S_OK;
	}

	return S_FALSE;
}

HRESULT STDMETHODCALLTYPE CMSDNView::OnCloseDataView(saf::safCloseAction *ca)
{
	*ca = saf::safCloseActionFree;

	return S_OK;
}
